package mx.com.fractal.ristorante.rest;

import javax.ejb.Singleton;
import javax.interceptor.Interceptors;
import javax.ws.rs.Consumes;
import javax.ws.rs.PUT;
import javax.ws.rs.Path;
import javax.ws.rs.PathParam;
import javax.ws.rs.Produces;
import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.Response;

import mx.com.fractal.ristorante.dto.PersonalDTO;
import mx.com.fractal.ristorante.exception.JdbcException;
import mx.com.fractal.ristorante.service.PersonalService;

import org.apache.log4j.Logger;
import org.jboss.resteasy.annotations.providers.jaxb.json.BadgerFish;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.ejb.interceptor.SpringBeanAutowiringInterceptor;

@Path("personal")
@Singleton
@Interceptors(SpringBeanAutowiringInterceptor.class)
public class PersonalRest {
	
	private static final Logger logger = Logger.getLogger(PersonalRest.class);

	@Autowired
	private PersonalService personalService;
	
	@PUT @BadgerFish
	@Path("save/{idRestaurante}")
	@Produces(value={MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML})
	@Consumes(value={MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML})
	public Response savePersonal(
			@PathParam("idRestaurante") Short idRestaurante,
			PersonalDTO personal){
		
		try {
			personal.setIdRestaurante(idRestaurante);
			personalService.save(personal);
		} catch (JdbcException e) {
			e.printStackTrace();
		}
		
		logger.trace("Request --> " + personal);
		return Response.ok().build();
		
	}
//	@GET
//	@Path("findby-numpersonal/{idRestaurante}/{numPersonal}")
//	@Produces(value={MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML})
//	public Response findPersonalByNumPersonal(
//			@PathParam("idRestaurante") Short idRestaurante,
//			@PathParam("numPersonal") Short numPersonal){
//		return Response.ok().build();
//	}
//	
//	@GET
//	@Path("get/{idRestaurante}")
//	@Produces(value={MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML})
//	public Response getPersonalByNumPersonal(
//			@PathParam("idRestaurante") Short idRestaurante,
//			@QueryParam("numPersonal") String numPersonal,
//			@QueryParam("idPersonal") Short idPersonal){
//		
//		PersonalDTO personal=new PersonalDTO();
//		personal.setIdPersonal(idPersonal);
//		personal.setNumPersonal(numPersonal);
//		
//		return Response.ok().build();
//	}
//	
//	@DELETE
//	@Path("delete/{idRestaurant}/{idPersonal}")
//	@Produces(value={MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML})
//	public Response deletePersonal(
//			@PathParam("idRestaurante") Short idRestaurante,
//			@PathParam("idPersonal") Short idPersonal){
//		
//		return Response.ok().build();
//	}
//	
//	@DELETE
//	@Path("deleteby-numpersonal/{idRestaurant}/{numPersonal}")
//	@Produces(value={MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML})
//	public Response deletePersonalByNumPersonal(
//			@PathParam("idRestaurante") Short idRestaurante,
//			@PathParam("numPersonal") Short numPersonal){
//		return Response.ok().build();
//	}
	
}
